#ifndef TRIPLEDES_H
#define TRIPLEDES_H
#include <Cipher.h>
#include <QObject>
#include <QMetaEnum>
#include <QString>
#include <QByteArray>
#include <openssl/sha.h>
#include <openssl/modes.h>

class TripleDES :public QObject,public QCipher
{
    Q_OBJECT
    public:
        enum Mode
        {
            ecb,
            cbc,
            cfb,
            ofb
        };
        Q_ENUM(Mode)
        TripleDES();
        bool encrypt(QByteArray &in, QByteArray &out, QByteArray &key, bool enc, Mode mode); //重载
        bool encrypt(QByteArray &in, QByteArray &out, QByteArray &key, bool enc, Mode mode, QByteArray &iv);
    private:
        QByteArray &ivec;
        Mode _mode; //算法模式
        void ecb_encrypt(const QByteArray &in, QByteArray &out, const QByteArray &key, bool enc);
        void cbc_encrypt(const QByteArray &in, QByteArray &out, const QByteArray &key,const QByteArray &ivec, bool enc);
        void cfb_encrypt(const QByteArray &in, QByteArray &out, const QByteArray &key,const QByteArray &ivec, bool enc);
        void ofb_encrypt(const QByteArray &in, QByteArray &out, const QByteArray &key,const QByteArray &ivec, bool enc);

};

#endif // TRIPLEDES_H
